<template>
  <ul class="container">
    <li v-for="(item, index) in data" :key="index" class="item">
      <div :class="['item_index', (index+1)%2 === 0?'item_bg_black':'item_bg_blue']"> {{ index+1 }}</div>
      <div :class="['item_content', (index+1)%2 === 0?'item_bg_black':'item_bg_blue']">
        <span v-for="(value, key, index) in item" :key="key" :style="[widthArray?{width:widthArray[index]}:'']">
          {{ value }}
        </span>
      </div>
    </li>
  </ul>
</template>
<script setup>
import { ref, defineProps } from 'vue';
const props = defineProps({
  data: {
    type: Array,
    default: () => []
  },
  //单位
  unit: {
    type: String,
    default: ''
  },
  widthArray: {
    type: Array,
    default: undefined
  }
});
</script>
<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.item {
  height: 2.5rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 3px;
}
.item_index {
  width: 2.125rem;
  height: 100%;
  line-height: 2.5rem;
}

.item_content {
  width: calc(100% - 2.75rem);
  height: 100%;
  padding: 0 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.625rem;
  align-items: center;
}

.item_bg_black {
  background: rgba(0, 0, 0, 0.1);
}

.item_bg_blue {
  background: rgba(148, 169, 218, 0.1);
}

.item_content > span {
  display: inline-block;
  text-overflow: ellipsis;
  overflow: hidden;
}
.item_content > span:first-child {
  text-align: start;
  width: 75%;
  white-space: nowrap;
}

.item_content > span:last-child {
  text-align: end;
  width: 25%;
  white-space: nowrap;
}
</style>
